#include <iostream>
#include <string.h>
#include <string>

using namespace std;

const int N = 5;

string grape[N] = {
    "     ",
    " @**@*",
    " **@**",
    " *@*@*",
};
int mark[N][N];

bool checkpos(int x, int y)
{
    if (x < 1 || x > 3 || y < 1 || y > 5)
    {
        return false;
    }
    if (grape[x][y] != '@' || 1 == mark[x][y])
    {
        return false;
    }
    return true;
}


int x[] = {0, 0, 1, -1, 1, 1, -1, -1};
int y[] = {1, -1, 0, 0, -1, 1, -1, 1};

void dfs(int x1, int y1)
{
    for (int i = 0; i < 8; ++i)
    {
        int nx = x1 + x[i];
        int ny = y1 + y[i];
        if (!checkpos(nx, ny))
        {
            continue;
        }
        mark[nx][ny] = true;
        dfs(nx, ny);
    }
}

int main(int argc, char *argv[])
{
    memset(&mark, 0, sizeof(mark));
    int ans = 0;
    for (int i = 1; i <= 4; ++i)
    {
        for (int j = 1; j <= 5; ++j)
        {
            if (checkpos(i, j))
            {
                dfs(i, j);
                ans ++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}
